#include "mainwidget.h"
#include "board.h"
#include "single.h"


#include <QGridLayout>
#include <QPushButton>


Mainwidget::Mainwidget(QWidget *parent) : QWidget(parent)
{
    this->setWindowTitle("象棋");

    QGridLayout *grid = new QGridLayout();

    QPushButton *btnboard = new QPushButton("单人游戏", this);
    this->connect(btnboard, SIGNAL(clicked()), this, SLOT(on_btnboard_clicked()));
    grid->addWidget(btnboard, 0, 0, 1, 1);


    QPushButton *btnsingle = new QPushButton("人机游戏", this);
    this->connect(btnsingle, SIGNAL(clicked()), this, SLOT(on_btnsingle_clicked()));
    grid->addWidget(btnsingle, 0, 1, 1, 1);

    this->setLayout(grid);

    this->setFixedSize(180, 50);

}



void Mainwidget::on_btnboard_clicked()
{
    //单人游戏
    chess_board = new Board();
    chess_board->show();
}

void Mainwidget::on_btnsingle_clicked()
{
    //人机游戏
    chess_board = new Single();
    chess_board->show();
}

